package myjava.test;

/**
 * @author Yancy
 * @program springioctest
 * @create 2020-09-02
 */
public class Computer {
  /**
   * 2/1，3/2，5/3，8/5，13/8，...的前n项求和
   *
   * @param n
   * @return
   */
  static double jiSuan(int n) {
    double sum =0.0;
    int number =0;
    int count = 1;
    //分母
    int denominator = 1;
    //分子
    int molecular = 2;
    while (count <= n){
      sum += (double)molecular/denominator;
      number = denominator + molecular;
      denominator = molecular;
      molecular = number;
      count++;
    }
    return sum;
  }
}
